package cn.edu.sdjzu.xg.eagle.service;

import cn.edu.sdjzu.xg.eagle.dao.UserDao;
import cn.edu.sdjzu.xg.eagle.entity.User;
import cn.edu.sdjzu.xg.eagle.factory.DaoFactory;
import cn.edu.sdjzu.xg.eagle.util.JdbcHelper;

import java.sql.Connection;
import java.sql.SQLException;

public final class UserServiceImpl implements UserService {
    private UserDao userDao =
            DaoFactory.getDao(UserDao.class, "UserDaoImpl");

    @Override
    public void login(User userToLogin) throws SQLException {
        try (Connection connection = JdbcHelper.getConn()) { // 使用 try-with-resources 自动关闭连接
            userDao.login(connection, userToLogin);
        }
    }
}
